import 'package:convergence_media/features/circle/riverpod/video_catgory.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';

class CatgoryList extends ConsumerWidget {
  const CatgoryList({super.key});

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final asyncValue = ref.watch(videoCatgoryProvider);
    return asyncValue.map(
      data: (data) {
        if (!data.hasValue) {
          return Container();
        }
        final list = data.value;
        return ListView.builder(
          itemCount: list.length,
          scrollDirection: Axis.horizontal,
          itemBuilder: (context, index) {
            return Container(
              width: 64.r,
              alignment: Alignment.center,
              child: Text(list[index]),
            );
          },
        );
      },
      error: (error) {
        return Text('Error:$error');
      },
      loading: (data) => const LinearProgressIndicator(),
    );
    // return switch (asyncValue) {
    //   AsyncValue<List<String>>(:final valueOrNull?) => ListView.builder(
    //       itemCount: valueOrNull.length,
    //       scrollDirection: Axis.horizontal,
    //       itemBuilder: (context, index) {
    //         return Container(
    //           width: 64.r,
    //           alignment: Alignment.center,
    //           child: Text(valueOrNull[index]),
    //         );
    //       },
    //     ),
    //   AsyncValue<List<String>>(:final error?) => Text('Error:$error'),
    //   _ => const LinearProgressIndicator(),
    // };
  }
}
